#include "myreplacedialog.h"
#include "ui_myreplacedialog.h"

MyReplaceDialog::MyReplaceDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MyReplaceDialog)
{
    ui->setupUi(this);

    //关联取消按钮与对话框关闭
    connect(ui->cancel, &QPushButton::clicked, this, &MyReplaceDialog::reject);
}

MyReplaceDialog::MyReplaceDialog(const QString &find_text, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MyReplaceDialog)
{
    ui->setupUi(this);

    //设置默认查找内容
    ui->edit_find->setText(find_text);

    //关联取消按钮与对话框关闭
    connect(ui->cancel, &QPushButton::clicked, this, &MyReplaceDialog::reject);
}

void MyReplaceDialog::on_replace_next_clicked()
{
    emit replace_next_clicked(ui->edit_find->text(), ui->edit_replace->text());
}

void MyReplaceDialog::on_replace_all_clicked()
{
    emit replace_all_clicked(ui->edit_find->text(), ui->edit_replace->text());
}

void MyReplaceDialog::on_skip_clicked()
{
    emit skip_clicked(ui->edit_find->text());
}

MyReplaceDialog::~MyReplaceDialog()
{
    delete ui;
}
